#include "LOGR_gen_info.h"

WebGenInfoPtr
new_gen_info_node(void)
{
  WebGenInfoPtr wgi = (WebGenInfoPtr)calloc(1, sizeof(WebGenInfoStruct));
  if(!wgi) {
      fprintf(stderr,"Out of Memory new_gen_info_node\n");
      abort();
  }
  return wgi;
}

void
delete_gen_info_node(WebGenInfoPtr wgi)
{	
    if(!wgi) return;
    free(wgi); wgi = NULL;
}

void
LOGR_set_gen_info_naccesses(WebGenInfoPtr wgi,long num)
{
  if(!wgi) return;
  wgi->naccesses = num;
}

void
LOGR_add_gen_info_naccesses(WebGenInfoPtr wgi,long num)
{
  if(!wgi) return;
  wgi->naccesses += num;
}

void
LOGR_inc_gen_info_naccesses(WebGenInfoPtr wgi)
{
  if(!wgi) return;
  wgi->naccesses++;
}

void *
LOGR_get_gen_info_context(WebGenInfoPtr wgi)
{
  if(!wgi) return NULL;
  return wgi->info;
}

void
LOGR_set_gen_info_context(WebGenInfoPtr wgi,void *info)
{
  if(!wgi) return;
  wgi->info = info;
}

long
LOGR_get_gen_info_naccesses(WebGenInfoPtr wgi)
{
  if(!wgi) return 0;
  return wgi->naccesses;
}


void
LOGR_set_gen_info_sizebytes(WebGenInfoPtr wgi,double num)
{
  if(!wgi) return;
  wgi->sbytes = num;
}

void
LOGR_add_gen_info_sizebytes(WebGenInfoPtr wgi,double num)
{
  if(!wgi) return;
  wgi->sbytes += num;
}

double
LOGR_get_gen_info_sizebytes(WebGenInfoPtr wgi)
{
  if(!wgi) return 0;
  return wgi->sbytes;
}


void
LOGR_set_gen_info_npages(WebGenInfoPtr wgi,long num)
{
  if(!wgi) return;
  wgi->npages = num;
}

void
LOGR_add_gen_info_npages(WebGenInfoPtr wgi,long num)
{
  if(!wgi) return;
  wgi->npages += num;
}

void
LOGR_inc_gen_info_npages(WebGenInfoPtr wgi)
{
  if(!wgi) return;
  wgi->npages++;
}

long
LOGR_get_gen_info_npages(WebGenInfoPtr wgi)
{
  if(!wgi) return 0;
  return wgi->npages;
}

int
LOGR_is_access_gen_info_lower(WebGenInfoPtr u, WebGenInfoPtr v)
{
  return (u->naccesses < v->naccesses);
}

int
LOGR_is_access_gen_info_bigger(WebGenInfoPtr u,WebGenInfoPtr v)
{
  return(u->naccesses > v->naccesses);
}

int
LOGR_is_npages_gen_info_lower(WebGenInfoPtr u, WebGenInfoPtr v)
{
  return (u->npages < v->npages);
}

int
LOGR_is_npages_gen_info_bigger(WebGenInfoPtr u,WebGenInfoPtr v)
{
  return(u->npages > v->npages);
}

int
LOGR_is_context_gen_info_lower(WebGenInfoPtr u, WebGenInfoPtr v)
{
  return ((int)u->info < (int)v->info);
}

int
LOGR_is_context_gen_info_bigger(WebGenInfoPtr u,WebGenInfoPtr v)
{
  return((int)u->info > (int)v->info);
}



